<?php

namespace App\Http\Controllers\system;

use App\Http\Controllers\Controller;
use App\Models\users\UsersModel;
use lxs\api\ApiResponse;

class StatisticsController extends Controller
{

    /**
     * 后台首页统计
     */
    public function getHomeStatisticsData() {

        $getLaxinNum = UsersModel::where('pid', '!=', 0)->count();

        $getLaxinOrderNum = 0;

        $getAmountTotal = UsersModel::sum('amount');

        $getCredit = UsersModel::sum('credit');

        $getData = [
            'get_laxin_num' => $getLaxinNum,
            'use_laxin_order_num' => $getLaxinOrderNum,
            'get_amount_total' => $getAmountTotal,
            'get_credit_total' => $getCredit,
        ];

        return ApiResponse::apiResponseData(200, '后台首页统计成功', [
            'getData' => $getData
        ]);

    }

}
